home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C13 / Newhandl.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  466 b   |  22 lines

  1. //: C13:Newhandl.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Changing the new-handler
  7. #include <iostream>
  8. #include <cstdlib>
  9. #include <new>
  10. using namespace std;
  11.  
  12. void out_of_memory() {
  13.   cerr << "memory exhausted!" << endl;
  14.   exit(1);
  15. }
  16.  
  17. int main() {
  18.   set_new_handler(out_of_memory);
  19.   while(1)
  20.     new int[1000]; // Exhausts memory
  21. } ///:~
  22.